package com.ruoyi.internet.api.factory;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.internet.api.RemoteIntUserService;
import com.ruoyi.internet.api.domain.IntUser;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;

/**
 * 文件服务降级处理
 *
 * @author ruoyi
 */
@Component
public class RemoteIntUserFallbackFactory implements FallbackFactory<RemoteIntUserService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteIntUserFallbackFactory.class);

    @Override
    public RemoteIntUserService create(Throwable throwable) {
        log.error("产业互联网服务调用失败:{}", throwable.getMessage());
        return new RemoteIntUserService() {
            @Override
            public R<IntUser> getUserInfoByUsernameOrPhone(@RequestBody IntUser intUser){
                return R.fail("获取用户失败:" + throwable.getMessage());
            }
        };
    }
}
